﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="废料入出库管理.aspx.cs" Inherits="syc.Store.废料入出库管理" %>
<html>
<head>
<title></title>
</head>
<body>
<script type="text/javascript" language="javascript" src="/common.js"></script>
<form id="form1" runat="server">
<asp:Label ID="SqlText" runat="server" Text="" Visible="false"></asp:Label>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
ConnectionString="<%$ ConnectionStrings:SCMConnectionString1 %>"
onselected="SqlDataSource1_Selected" 
DeleteCommand="delete from 废料入出库 where ID=@ID;update  废料到发记录 set 单据ID=0 where 单据ID=@ID; "
>
<DeleteParameters>
<asp:Parameter Name="ID" DbType="Int32" Size="4"/>
</DeleteParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" 
    ConnectionString="<%$ ConnectionStrings:SCMConnectionString1 %>" 
    SelectCommand="select 0 as ID,'全部' as 名称 union SELECT [ID], [名称] FROM [废料收货单位]"></asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource3" runat="server" 
ConnectionString="<%$ ConnectionStrings:SCMConnectionString1 %>" 
SelectCommand="select 0 as ID,'全部' as 废料名称 union select ID, 废料名称 FROM 废料"></asp:SqlDataSource>
<div id="wintop" class="wintop">废料入库管理</div>

<asp:Panel ID="Panel1" runat="server" CssClass="panel">
     &nbsp;
    <asp:Button ID="Button_Edit" runat="server" Text="修 改" CssClass="button75"  
        UseSubmitBehavior="False"  onclick="Button_Edit_Click"/>
    <asp:Button ID="Button_Delete" runat="server" Text="删 除" CssClass="button62"  
        UseSubmitBehavior="False" 
        onclick="Button_Delete_Click"
        OnClientClick="if(!confirm('确认要删除该条记录吗？'))return(false);" />
</asp:Panel>


<asp:Panel ID="Panel2" runat="server" CssClass="panel" GroupingText="废料记录查询">

    废&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 料： <asp:DropDownList ID="LeiBie" runat="server" 
        DataSourceID="SqlDataSource3" Width="140px"
        DataTextField="废料名称" DataValueField="ID" style="height: 22px">
    </asp:DropDownList>

  <span style="margin-left:8px;"></span>  生产单位：<asp:DropDownList ID="FenChang" runat="server" Width="121px">
        <asp:ListItem Text="全部" Value="0"></asp:ListItem>
        <asp:ListItem Text="一分厂" Value="1"></asp:ListItem>
        <asp:ListItem Text="二分厂" Value="2"></asp:ListItem>
        <asp:ListItem Text="三分厂" Value="3"></asp:ListItem>
        <asp:ListItem Text="四分厂" Value="4"></asp:ListItem>
        <asp:ListItem Text="五分厂" Value="5"></asp:ListItem>
    </asp:DropDownList>
<span style="margin-left:8px;"></span> 收货单位：<asp:DropDownList ID="ShouHuoDanWei" 
        runat="server" Width="121px" DataSourceID="SqlDataSource2" DataTextField="名称" 
        DataValueField="ID">       
    </asp:DropDownList>
<div style="font-size:6px;height:6px;line-height:6px;"></div>
状态筛选：&nbsp;&nbsp;<asp:DropDownList ID="XianShi" runat="server" Width="140px">
<asp:ListItem Value="0">全部显示记录</asp:ListItem>
<asp:ListItem Value="1">已入库</asp:ListItem>
<asp:ListItem Value="2">已出库</asp:ListItem>
</asp:DropDownList>
<span style="margin-left:8px;"></span>起始日期：<asp:TextBox ID="Date1" runat="server" CssClass="textbox" Width="105px"></asp:TextBox><img alt="" src="/Icons/29.png" align="middle" onclick="makecalendar(document.getElementById('Date1').value, document.getElementById('Date1'));" />
<span style="margin-left:8px;"></span>截止日期：<asp:TextBox ID="Date2" runat="server" CssClass="textbox" Width="105px"></asp:TextBox><img alt="" src="/Icons/29.png" align="middle" onclick="makecalendar(document.getElementById('Date2').value, document.getElementById('Date2'));" />

<span style="margin-left:5px;"></span><asp:Button ID="Button_Query" runat="server" Text="查 询" UseSubmitBehavior="false" 
        CssClass="mbutton" onclick="Button_Query_Click" />

<asp:Button ID="Button_Reset" runat="server" Text="清空条件" UseSubmitBehavior="false" 
        CssClass="mbutton" onclick="Button_Reset_Click" />
</asp:Panel>

<div class="gridframe">
    <div class="gridview">
    
        <table border="1" width="100%" cellspacing="0" cellpadding="0" bordercolor="#e5cfab">
            <tr>
	            <td class="grid-title"><div style="float:left;margin-top:3px;">废料入、出库记录</div><div style="float:right;">
                    <asp:DropDownList ID="PageSizeOption" runat="server" AutoPostBack="True" 
                        onselectedindexchanged="PageSizeOption_SelectedIndexChanged">
                    <asp:ListItem Value="10">10 项/页</asp:ListItem>
                    <asp:ListItem Value="20" Selected="True">20 项/页</asp:ListItem>
                    <asp:ListItem Value="30">30 项/页</asp:ListItem>
                    <asp:ListItem Value="50">50 项/页</asp:ListItem>
                    <asp:ListItem Value="100">100 项/页</asp:ListItem>
                    </asp:DropDownList></div>
	            </td>
	        </tr>
	        <tr>
	            <td class="grid-back">
                    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
                        AutoGenerateColumns="False" CssClass="grid" DataKeyNames="ID,入出" 
                        DataSourceID="SqlDataSource1"
                        PageSize="20"
                        GridLines="None" ondatabound="GridView1_DataBound" 
                        onpageindexchanged="GridView1_PageIndexChanged" AllowSorting="True" 
                        UseAccessibleHeader="False" 
                        onselectedindexchanged="GridView1_SelectedIndexChanged" >
                        <PagerSettings Visible="False" />
                        <RowStyle CssClass="grid-row-normal" />
                        <Columns>
                           <asp:TemplateField HeaderText="">
                                    <ItemTemplate>
                                        <asp:Button ID="Button_xz" runat="server" CommandName="Select" Text="选择" CssClass="hide"/>
                                        <img src="/Icons/online.gif" style="margin-top:2px;" alt="" />
                                    </ItemTemplate>
                                    <HeaderStyle CssClass="grid-header" />                                    
                                    <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="20px" />
                                </asp:TemplateField>
                            
                            <asp:TemplateField HeaderText="入出">
                                <ItemTemplate>
                               
                                    <img src='/Images/io-<%# Eval("入出") %>.png' />
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="30px" />
                            </asp:TemplateField>
                            
                             <asp:TemplateField HeaderText="单据号">
                                <ItemTemplate>
                                    <asp:Label ID="Label_djh" runat="server" Text='<%# Eval("单据号","{0:D7}") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="50px" />
                            </asp:TemplateField>
                            
                            <asp:TemplateField HeaderText="废料名称" SortExpression="废料名称">
                                <ItemTemplate>
                                    <asp:Label ID="Label_pm" runat="server" Text='<%# Eval("废料名称") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="100px" />
                            </asp:TemplateField>
                            
                             <asp:TemplateField HeaderText="规格" SortExpression="规格">
                                <ItemTemplate>
                                    <asp:Label ID="Label_gg" runat="server" Text='<%# Eval("规格") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="100px" />
                            </asp:TemplateField>                            
                            
                            
                            <asp:TemplateField HeaderText="填报(收货)单位">
                                <ItemTemplate>
                                    <asp:Label ID="Label_gy" runat="server" Text='<%# Eval("供货或使用") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" Width="100px"  HorizontalAlign="Center" />
                            </asp:TemplateField>
                            
                            <asp:TemplateField HeaderText="数量">
                                <ItemTemplate>
                                    <asp:Label ID="Label_zs" runat="server" Text='<%# Eval("数量") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="50px" />
                            </asp:TemplateField>                        
                                                   
                           <asp:TemplateField HeaderText="单价">
                                <ItemTemplate>
                                    <asp:Label ID="Label_dj" runat="server" Text='<%# Eval("单价") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="right" Width="60px" />
                            </asp:TemplateField>
                            
                            <asp:TemplateField HeaderText="结存数量">
                                <ItemTemplate>
                                    <asp:Label ID="Label_jcsl" runat="server" Text='<%# Eval("结存数量") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="right" Width="90px" />
                            </asp:TemplateField>
                            
                            <asp:TemplateField HeaderText="结存金额">
                                <ItemTemplate>
                                    <asp:Label ID="Label_jcje" runat="server" Text='<%# Eval("结存金额") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="right" Width="90px" />
                            </asp:TemplateField>                             
                            <asp:TemplateField HeaderText="日期" SortExpression="日期">
                                <ItemTemplate>
                                    <asp:Label ID="Label_dh" runat="server" Text='<%# Eval("日期","{0:d}") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="70px" />
                            </asp:TemplateField>
                               
                        
                            
                           
                            
                        </Columns>
                        <SelectedRowStyle CssClass="grid-row-selected" />
                      </asp:GridView>
	            </td>
            </tr>
            <tr>
	            <td>   
	                <table width="100%">
	                    <tr>
	                        <td class="pagebar">
                                <asp:Button ID="Button_Pager_First" UseSubmitBehavior="false" runat="server" Text="" ToolTip="首页" 
                                    CssClass="pageturn-first-b" onclick="Pager_Click" CommandName="--" />
                                <asp:Button ID="Button_Pager_Prev" UseSubmitBehavior="false" runat="server" Text="" ToolTip="上一页" 
                                    CssClass="pageturn-prev-b" onclick="Pager_Click" CommandName="-" />
                                <input type="button" class="page-split" UseSubmitBehavior="false" disabled />第<asp:TextBox 
                                    ID="TextBox_Pager" AutoPostBack="True" runat="server" CssClass="pageturn" 
                                    ontextchanged="Pager_Click"></asp:TextBox>页<input type="button" class="page-split" disabled /><asp:Label ID="Label_Pages" UseSubmitBehavior="false" runat="server"></asp:Label><input type="button" class="page-split" disabled />
                                 
                                <asp:Button ID="Button_Pager_Next" UseSubmitBehavior="false" runat="server" Text="" ToolTip="下一页" 
                                    CssClass="pageturn-next-b" onclick="Pager_Click" CommandName="+" />
                                <asp:Button ID="Button_Pager_Last" UseSubmitBehavior="false" runat="server" Text="" ToolTip="末页" 
                                    CssClass="pageturn-last-b" onclick="Pager_Click" CommandName="++" /><input type="button" class="page-split" disabled />
                            </td>
                            <td class="pagebar" align="right">
                                <asp:Label ID="Label_Total" runat="server"></asp:Label>
                            </td>
                        </tr>
                   </table>

	            </td>
            </tr>
        </table>
        

    </div>
</div>
</form>
<script>
    var notice = '<%=this.Notice %>';
    if (notice != '') {
        parent.showmsgbox(notice);
    }
    var textboxs = document.getElementsByTagName("input");
    var i;
    for (i = 0; i < textboxs.length; i++) {
        if (textboxs[i].className == "textbox") {
            textboxs[i].onchange = function(e) { this.className = "textbox-changed"; };
            textboxs[i].onfocus = function(e) { this.select(); };
        }
        else if (textboxs[i].className == "pageturn" || textboxs[i].className == "intxt1" || textboxs[i].className == "intxt2") {
            textboxs[i].onfocus = function(e) { this.select(); };
        }

    }
    var rows = document.getElementsByTagName("tr");
    for (i = 0; i < rows.length; i++) {

        if (rows[i].className == "grid-row-normal") {
            rows[i].onmouseover = function() { this.className = "grid-row-bright"; };
            rows[i].onmouseout = function() { this.className = "grid-row-normal"; };
            rows[i].onclick = function() { this.firstChild.firstChild.click(); };
        }
    }
    var tds = document.getElementsByTagName("td");
    for (i = 0; i < tds.length; i++) {
        if (tds[i].className == "detailheader") {
            tds[i].innerHTML = tds[i].innerHTML.replace("*", "<span class=required>*</span>");
        }
    }

    document.onkeydown = function(e) {
        if (!e) e = window.event;
        var tag = e.srcElement;
        if (!tag) tag = e.target;
        if (tag.tagName == "INPUT" && tag.className == "textbox" || tag.tagName == "SELECT") {
            if (e.keyCode == 13) e.keyCode = 9;
        }
    }
    var rows = document.getElementById("GridView1").rows;
    var sum1 = 0, sum2 = 0, sum3 = 0, sum4 = 0;
    var n1, n2;
    for (i = 1; i < rows.length; i++) {
        n1 = Number(rows[i].cells[6].innerText);
        n2 = Number(rows[i].cells[7].innerText)
        if (n1 >= 0) {
            sum1 += n1;
            sum3 += n1 * n2;
        }
        else {
            sum2 += n1;
            sum4 += n1 * n2;
        }
    }
    var total = document.getElementById("Label_Total");
    total.innerHTML += "</br>本页小计：" + (rows.length - 1) + " 项 入库：" + fixFloatZ(sum1, 3) + " 金额：" + fixFloatZ(sum3, 2) + " 元 出库：" + fixFloatZ(Math.abs(sum2), 3) + " 金额：" + fixFloatZ(Math.abs(sum4), 2) + " 元 ";
    
</script>
</body>
</html>

